<%@ page import="org.gnomus.server.Context" %>
<%@ page import="org.gnomus.util.io" %>
<%@ page import="java.io.File" %>
<%@ page import="java.util.Map" %>
<%
  Context ctx = Context.get();
  Map lesson = (Map) ctx.data.get("lesson");
  Map item = (Map) ctx.data.get("item");
  Map activity = (Map) ctx.data.get("activity");
  String type = activity == null ? null : (String) activity.get("type");
%>
<%
  if (lesson != null && item != null && activity != null) {
%>
<div>
  <p class="xlarge b">
    <a href="/lesson/edit?id=<%= lesson.get("id") %>">
    <%= lesson.get("title") %>
    </a>
  </p>
  <p class="large">
    <a href="/item/edit?id=<%= item.get("id") %>">
      Assignment : <%= item.get("title") %>
    </a>
  </p>
  <hr />
  <%
    if ("edit".equals(ctx.action) &&
            io.exists(new File("WEB-INF/activity/" + type + ".jsp"))) {
      String p = "/WEB-INF/activity/" + type + ".jsp"; // prevent null pointer exception (do not inline)
    %>
  <div id="activity_edit">
    <jsp:include page="<%= p %>"></jsp:include>
  </div>
  <%
    } else {
  %>
  Activity type = "<%= type %>" not found or action = "<%= ctx.action %>" not recognized.
  <%
    }
  %>
</div>
<%
  }
%>
